package com.second.app.textfiff;

public class TextDiff {
    public static int countDiffTriplets(String text1, String text2) {
        int len = Math.min(text1.length(), text2.length());
        int count = 0;

        for (int i = 0; i <= len - 3; i++) {
            String sub1 = text1.substring(i, i + 3);
            String sub2 = text2.substring(i, i + 3);

            boolean allDiff = true;
            for (int j = 0; j < 3; j++) {
                if (sub1.charAt(j) == sub2.charAt(j)) {
                    allDiff = false;
                    break;
                }
            }

            if (allDiff) count++;
        }

        return count;
    }

    public static void main(String[] args) {
        String text1 = "Hello世界abc";
        String text2 = "Hella世qiabd";
        int result = countDiffTriplets(text1, text2);
        System.out.println("连续3个字符完全不一样的次数：" + result);
    }
}
